#Include <..\include\Common_For_PageManager.au3>
#Include <GuiButton.au3>
#Include <GuiTreeView.au3>

Dim Const $sFunctionFolderPath = "C:\"&$sSectionNameDocumentPallet&"\"
Dim Const $SamplePatch = "C:\"&$sSectionNameDocumentPallet&"\Sample\"
Dim Const $CorrectResutPath = "C:\"&$sSectionNameDocumentPallet&"\Correct Result\"
Dim Const $PerformResultPath = "C:\"&$sSectionNameDocumentPallet&"\Perform Result\"
Global Const $sExcelSheetName = 'Document Pallet'
Global Const $iRescolumn = 14
Dim Const $iNumber = Common_GetNumberInExcelSheet($oExcel,$sDocumentPalletFunctionName)  
Dim Const $iCurrentSheetTotalLineNumber = $iNumber[0]   ;Get all number of rows in current excel sheet.


Global $tDocumentPallet = "Document Pallet Settings"
Dim Const $sPMFolderPath=@MyDocumentsDir&"\"&$sMyPageManagerSampleFolder&"\"

Dim Const $FileName_1 = "Copy of BMP_16Bit.bmp"
Dim Const $FileName_2 = "Copy of BW_100DPI.TIF"
Dim Const $FileName_3 = "Copy of JPEG_Color.jpg"
Dim Const $FileName_4 = "Copy of TIFF_8Bit.tif"

;Common_WriteLog($sFaile & $MunalExecuteTestCase & ' --- ' & '' , $TestCaseID,$sDocumentPalletFunctionName,$bReproduceTestCase) 
;Common_WriteLog($sFaile & $CompareScreenCapture , $TestCaseID,$sDocumentPalletFunctionName,$bReproduceTestCase) 
;Read INI vale

Dim Const $sDocumentPalletListView			= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletListView'))
Dim Const $sDocumentPalletStatusBar			= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletStatusBar'))
Dim Const $sDocumentPalletSettingCancel		= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletSettingCancel'))
Dim Const $sDocumentPalletSettingOK			= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletSettingOK'))
Dim Const $sDocumentPalletSettingBrowse		= Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletSettingBrowse'))
Dim Const $sDocumentPalletSendByMail        = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletSendByMail'))
Dim Const $sDocumentPalletOutlook           = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletOutlook'))
Dim Const $sOutLookTitle 				    = ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, "OutLookTitle")
Dim Const $sDocumentPalletBrowseTree 		= ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, "DocumentPalletBrowseTree")
Dim Const $sDocumentPalletSettingConvert    = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'DocumentPalletSettingConvert'))
Dim Const $sUnstackButtonInToolbar          = Number(ReadIniKeyValue($sPCodeIniPath, $sSectionNameDocumentPallet, 'UnstackButtonInToolbar'))
Dim Const $sDocuments 					    = ReadIniKeyValue($sPCodeIniPath, $sSectionNameTreeView, 'Documents')

Func InitializeStatusForDocumentPallet()
	
EndFunc

	
Func SendFolder($folder)
	Local $title = "Browse For Folder"
	ControlTreeView($title, "", $sDocumentPalletBrowseTree,"Expand","#0|#1|#2")
	Sleep(500)
	Local $TreeViewHandle = ControlGetHandle($title, "",$sDocumentPalletBrowseTree)
	Local $Item = _GUICtrlTreeView_FindItem($TreeViewHandle, $sDocuments)
	If $Item = 0 Then $Item = _GUICtrlTreeView_FindItem($TreeViewHandle, "My Documents")
	Sleep(500)
	_GUICtrlTreeView_ClickItem($TreeViewHandle, $Item)
	_GUICtrlTreeView_SelectItem($TreeViewHandle, $Item)
	Sleep(300)
	$Item = _GUICtrlTreeView_FindItem($TreeViewHandle, $folder)
	Sleep(500)
	_GUICtrlTreeView_ClickItem($TreeViewHandle, $Item)
	_GUICtrlTreeView_SelectItem($TreeViewHandle, $Item)
	Sleep(300)	
	ControlClick($title, "", 1)
	Sleep(300)
EndFunc	
	
Func OpenDocumentPallet($hPMHandle)
	; Open documnet pallet.
	Local $posDocumentPallet = ControlGetPos($hPMHandle,"",$sDocumentPalletStatusBar)	
	MouseClick("left",$posDocumentPallet[0]+$posDocumentPallet[2]-10,$posDocumentPallet[1]+$posDocumentPallet[3]+10)
	Sleep(500)
EndFunc

Func DocumentSettings($hPMHandle)
	Local $posDocumentPallet = ControlGetPos($hPMHandle,"",$sDocumentPalletListView)	
	MouseClick("left",$posDocumentPallet[0]+$posDocumentPallet[2]-22,$posDocumentPallet[1]+8)
	Sleep(800)
EndFunc

Func Sendfiles($hPMHandle)
	Local $posDocumentPallet = ControlGetPos($hPMHandle,"",$sDocumentPalletListView)	
	MouseClick("left",$posDocumentPallet[0]+$posDocumentPallet[2]-62,$posDocumentPallet[1]+8)
	Sleep(800)
EndFunc

Func TaskBar($Status)
	MouseMove(652, 772)
	Sleep(300)
	MouseClick("right", 696, 753)
	Sleep(300)
	Send("r")
	Sleep(800)
	$autoHide = _GUICtrlButton_GetCheck(ControlGetHandle("Taskbar and Start Menu Properties", "", 1102))
	$shown = _GUICtrlButton_GetCheck(ControlGetHandle("Taskbar and Start Menu Properties", "", 1101))
	If $Status = "show" Then
		If $autoHide = 1 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1102)
		EndIf
		If $shown = 0 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1101) 
		EndIf
		ControlClick("Taskbar and Start Menu Properties", "", 1)
		Sleep(300)
		MouseClick("left", 204, 159)
		Sleep(500)
	EndIf
	If $Status = "notShow" Then
		If $autoHide = 0 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1102)
		EndIf
		If $shown = 1 Then
			ControlClick("Taskbar and Start Menu Properties", "", 1101) 
		EndIf
		ControlClick("Taskbar and Start Menu Properties", "", 1)
		Sleep(300)
		MouseClick("left", 204, 159)
		Sleep(500)
	EndIf	
EndFunc

Func CloseOutlookActivationDialog()
	If WinExists("Microsoft Office Activation Wizard", "") Then
		WinActivate("Microsoft Office Activation Wizard", "")
		Sleep(500)
		Send("{ESC}")
		Sleep(1000)
	EndIf
EndFunc

Func SwitchToSampleFolder($hPMHandle)
	Local $hTree = ControlGetHandle($hPMHandle, "", $sTreeViewCtrInfo)
	Local $hItemFound1 = _GUICtrlTreeView_FindItem($hTree, "Sample")
	_GUICtrlTreeView_ClickItem($hTree, $hItemFound1)	
	Sleep(300)
	Common_SleepTime(2)	
	WinActivate($hPMHandle)
EndFunc

Func CopySamppleToPMFolder()
	FileCopy($COMMON_SAMPLES_FOLDER_PATH & 'JPEG_Color.jpg', $PMFolder, 1)
	Sleep(500)
	Send('{F5}')
	Sleep(500)
EndFunc

Func CopySamppleToPMFolder2()
	FileCopy($COMMON_SAMPLES_FOLDER_PATH & 'JPEG_Color.jpg', $PMFolder, 1)
	FileCopy($COMMON_SAMPLES_FOLDER_PATH & 'BW_100DPI.TIF', $PMFolder, 1)
	FileCopy($COMMON_SAMPLES_FOLDER_PATH & 'TIFF_8Bit.tif', $PMFolder, 1)
	FileCopy($COMMON_SAMPLES_FOLDER_PATH & 'BMP_16Bit.bmp', $PMFolder, 1)
	Sleep(500)
	Send('{F5}')
	Sleep(500)
EndFunc